package com.chixing.controller;

import com.chixing.service.HotCarService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HotCarController {
    @Autowired
    private HotCarService hotCarService;
    @GetMapping("hotcar")
    public ModelAndView toHotCar(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("car_rental/hot_car");
        return modelAndView;
    }
    @GetMapping("hotcar/{carType}/{carBrand}")
    @ResponseBody
    public ServerResponse getHotCar(@PathVariable("carType") String carType,
                                    @PathVariable("carBrand") String carBrand){
        return hotCarService.getHotCar(carType,carBrand);
    }
}
